<template>
	<fieldset>
		<legend>cart</legend>
		{{$store.state.product}}
		<button @click="FETCH_PRODUCT">点击获取购物车数据</button>
        <ul>
            <li v-for="item in product" :key="item.id">
                {{item.title}}
            </li>
        </ul>
	</fieldset>
</template>
<script>
	import { mapActions,mapState } from "vuex"
	//需要映射在methods中
	export default {
        computed:{
            ...mapState(['product'])
        },
		methods: {
			getPro() {
				//传统方法
				this.$store.dispatch("FETCH_PRODUCT", 20)
			},
			...mapActions(['FETCH_PRODUCT'])
		}
	}
</script>